package cn.csxw.openchina.dagger2.presenter;


import java.util.ArrayList;

import javax.inject.Inject;

import cn.csxw.openchina.entity.bean.EventBean;
import cn.csxw.openchina.entity.bean.OsChinaBean;
import cn.csxw.openchina.ui.fragment.exerciseFragment.RecentlyExerciseFragment;
import retrofit2.Call;

/**
 * 近期活动的  加载网络数据
 */

public class RecentlyFragmentPresenter extends BasePresenter {
    RecentlyExerciseFragment mRecentlyExerciseFragment;
    private ArrayList<EventBean> mActiveBeen;

    @Inject
    public RecentlyFragmentPresenter(RecentlyExerciseFragment recentlyExerciseFragment) {
        mRecentlyExerciseFragment = recentlyExerciseFragment;
    }

    @Override
    protected void processData(OsChinaBean data) {
        if (data != null) {
            mActiveBeen = (ArrayList<EventBean>) data.events;
            if(mRecentlyExerciseFragment.mRecentlyAdapter.getData().size()!=0){
                mRecentlyExerciseFragment.mRecentlyAdapter.addData(mActiveBeen);
            }else{
                mRecentlyExerciseFragment.mRecentlyAdapter.setData(mActiveBeen);
            }
        }
    }

    @Override
    public void callNetWork(Object... params) {
        Call<OsChinaBean> recentlyfInfo =
                mOsChinaServer.getEventInfo((String) params[0], (int) params[1], (int) params[2]);
        recentlyfInfo.enqueue(mCallback);
    }
}
